//
//  ViewController.m
//  团购
//
//  Created by app43 on 15/6/21.
//  Copyright (c) 2015年 www.xcu.edu.cn. All rights reserved.
//

#import "ViewController.h"
#import "MJExtension.h"
#import "MJTG.h"
#import "MJTGCell.h"
#import "MJHeader.h"

@interface ViewController ()<UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) NSArray *tgs;


@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    
    ///段尾
    self.tableView.rowHeight = 80;
    
    UIButton *footer = [UIButton buttonWithType:UIButtonTypeSystem];
    footer.frame = CGRectMake(0, 0, 0, 35);
    
    footer.backgroundColor = [UIColor orangeColor];
    
    [footer setTitle:@"查看全部团购" forState:UIControlStateNormal];
    
    self.tableView.tableFooterView = footer;
    //
    
    
    //段头
    self.tableView.tableHeaderView = [MJHeader header];
}

//隐藏状态栏
- (BOOL)prefersStatusBarHidden
{
    return YES;
}



///读取tgs.plist
- (NSArray *)tgs
{
    if (_tgs == nil) {
        _tgs = [MJTG modelArrayWithFilename:@"tgs.plist"];
    }
    return _tgs;
}



/////////biao

//行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.tgs.count;
}

//行的cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    //////////////////////重写  建造静态cell   当cell ==nil 时 加载 cell.nib
    MJTGCell *cell = [MJTGCell cellWithTableView:tableView];
    
    
    
    
  
    //////////////赋值
    //重写tg赋值    ==    莫 的 {当前行}
    cell.tg = self.tgs[indexPath.row];
    return cell;
}


@end
